package com.dq.Week3.day11.homeWork;

import java.util.Iterator;
import java.util.Random;

public class StrIterator implements Iterator<String> {

    private final int MAX_NUMBER = 10;
    private int count= 0;
    private Random r= new Random();


    public static void main(String[] args) {
        Iterator<String> iterator = new StrIterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }

    @Override
    public boolean hasNext() {
        return count < MAX_NUMBER;
    }

    @Override
    public String next() {
        if (!hasNext()) {
            throw new IllegalStateException("Iterator has reached its limit");
        }
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < 10; i++) {
            sb.append((char)('a'+r.nextInt(26)));
        }
        count++;
        return sb.toString();
    }


}
